function shearplots = plotWSSsummary(SV_parameters)

WkgDir      = SV_parameters.wkgdir;
WkspaceName = SV_parameters.wkspaceName;
saveFLAG    = SV_parameters.includeDB;
intrpmeth   = SV_parameters.interp(2:end);
if saveFLAG
    PatientDB      = SV_parameters.DBname;
    if isfield(SV_parameters,'DBsubtype')
        PatientDB_type = SV_parameters.DBsubtype;
    else
        PatientDB_type = '';
    end
else
    PatientDB      = 'temp';
    PatientDB_type = '';
end
filename = SV_parameters.PatientID;

load([WkgDir '\_wkspce\' intrpmeth '_' WkspaceName])
    
calcpolarWSS % note that printFLAG and movieFLag = 1 will drastically slow things down

N            = size(pWSS,2);
meanWSS(1:N) = NaN;

for i = 1:N
    
    tempWSS = pWSS(:,i);
    tempWSS = tempWSS(~isnan(tempWSS)); % remove Nan's
    meanWSS(i) = mean(tempWSS);
    
end

taumean = mean(meanWSS);              % magnetude of the time avg'd WSS
taumag  = (sum(abs(meanWSS)))/N;      % time avg of WSS magnetudes
OSIcirc = .5*(1-abs(taumean)/taumag); % circumferential oscillatory shear indices

shearplots = figure('Position', [0 0 800 800],'Color','w');

%% Plot Flow information

flowplot = axes('OuterPosition', [0 .655 .82 0.32]);
plot(negativeFlow,'Color','red', 'LineWidth',1);
hold on
plot(positiveFlow,'Color','g','LineWidth',1);
plot(flowRateVsTime,'Color','b','Marker','o','LineWidth',2);
set(get(flowplot,'Title'),'String','Flow Rate vs Time','FontSize',10,'FontWeight','Bold');
set(get(flowplot,'XLabel'),'String','Phase','FontSize',10);
set(get(flowplot,'YLabel'),'String','Flow Rate [L/min]','FontSize',10);
grid on
axis([1 size(WSSlocal,2) min(negativeFlow)*1.05 max(positiveFlow)*1.05])
timeline = plot([SystoleFrame SystoleFrame],[min(negativeFlow)*1.05 max(positiveFlow)*1.05],'Color','r','LineWidth',2);
hold off
leg = legend('Negative Flow', 'Positive Flow', 'Net Flow Rate');
set(leg,'EdgeColor',[1 1 1],'FontSize',8,'OuterPosition',[.76 .879 .166 0.073])


%% Plot local WSS values
localmeans = axes('OuterPosition', [0 .05 .82 0.33]);
plot(WSSlocal(1,:), 'k', 'DisplayName', '\tau_0', 'YDataSource', 'WSSdeg0');
hold on
plot(WSSlocal(2,:),':k', 'DisplayName', '\tau_{45}', 'YDataSource', 'WSSdeg45');
plot(WSSlocal(3,:),'b', 'DisplayName', '\tau_{90}', 'YDataSource', 'WSSdeg90');
plot(WSSlocal(4,:),':b', 'DisplayName', '\tau_{135}', 'YDataSource', 'WSSdeg135');
plot(WSSlocal(5,:),'r', 'DisplayName', '\tau_{180}', 'YDataSource', 'WSSdeg180');
plot(WSSlocal(6,:),':r', 'DisplayName', '\tau_{225}', 'YDataSource', 'WSSdeg225');
plot(WSSlocal(7,:),'g', 'DisplayName', '\tau_{270}', 'YDataSource', 'WSSdeg270');
plot(WSSlocal(8,:),':g', 'DisplayName', '\tau_{315}', 'YDataSource', 'WSSdeg315');
title('Local \tau Values, (0\circ,45\circ,...)','FontWeight','Bold')
xlabel('Phase');
ylabel('Local WSS, \tau (dynes/cm^2)')
h = findobj(localmeans,'Type','line');
set(h,'LineWidth',1)
a = axis;
plot(meanWSS,'b','DisplayName','\tau_{circmean}','LineWidth',2,'Marker','s', 'MarkerSize',5);
plot([SystoleFrame SystoleFrame],[a(3),a(4)],'r','LineWidth',2,'DisplayName', 'Systole');
plot([1 size(WSSlocal,2)],[0 0],':k','LineWidth',1,'DisplayName', 'y=0');
clear a
hold off

% add in the circuferential OSI and tau mean values
xlim   = .70;
ylim   = .1;
yspace = .05;
text(xlim,ylim + yspace*2, ['time \tau_{mean} = ' num2str(taumean,3) ' dyn/cm^2'], 'Color', 'k', 'FontSize',8, 'Units','normalized');
text(xlim,ylim + yspace,   ['time \tau_{mag}  = ' num2str(taumag,3) ' dyn/cm^2'], 'Color', 'k', 'FontSize',8,'Units','normalized');
text(xlim,ylim,            ['OSI           = ' num2str(OSIcirc,2)], 'Color', 'k', 'FontSize',8,'Units','normalized');

% add in the OSI value to the legend
[leg lobj lplot lstrings] = legend('toggle');
for i = 1:8
    taulocalmean(i) = mean(WSSlocal(i,:));
    taulocalmag(i)  = (sum(abs(WSSlocal(i,:))))/N;
    OSIlocal(i)     = 0.5*(1-abs(taulocalmean(i))/taulocalmag(i));
    lstrings(i) = strcat(lstrings(i), ', OSI = ',num2str(OSIlocal(i),2));
end
leglocal = legend(lplot,lstrings,'Position',[0.7475 0.0776 0.195 0.2879]);
set(leglocal,'Color','none','EdgeColor',[1 1 1],'FontSize',8)
set(leglocal, 'Position', [0.76 0.08 0.195 0.28])
locallimits   = axis;
axis([1 size(WSSlocal,2) locallimits(3:4)]);


%% Plot Velocity Profile at systole (WSS?); regurg, reversal ratios

centerx=stats(SystoleFrame).Centroid(1);
centery=stats(SystoleFrame).Centroid(2);
x = find(b(:,2,SystoleFrame) > 0);
y = find(b(:,1,SystoleFrame) > 0);
roisize = size(x,1);

hVelMap = axes('OuterPosition', [.075 .34 .26 .353]);
himage = surf(VelDironeVelDataMask(:,:,SystoleFrame),'CDataMapping', 'scaled','EdgeColor','none');
view(2); axis square; axis ij; box on; hold on
axis([limits(1)+centerx limits(2)+centerx limits(3)+centery limits(4)+centery]);
set(get(hVelMap,'Title'),'String',['Vel. Map@Sys (cm/s)'],'FontSize',10,'FontWeight','Bold');
text(Xmin+XTextSpacer,Ymax-1*YTextSpacer,['Avg. Vel. = ' num2str(avgVelocityVsTime(SystoleFrame),3) ' cm/s'], 'Color', 'k', 'FontSize',8);
text(Xmin+XTextSpacer,Ymax-2*YTextSpacer,['Peak Vel. = ' num2str(peakVelocityVsTime(SystoleFrame),3) ' cm/s'], 'Color', 'k', 'FontSize',8);
text(Xmin+XTextSpacer,Ymin+YTextSpacer,['Q = ' num2str(flowRateVsTime(SystoleFrame),3) ' L/min'], 'Color', 'k', 'FontSize',8);
text(Xmin+XTextSpacer,Ymin+2*YTextSpacer,['Qavg = ' num2str(FlowRate,3) ' L/min'], 'Color', 'k', 'FontSize',8);
set(get(hVelMap,'YLabel'),'String','Pixels','FontSize',10);
set(get(hVelMap,'XLabel'),'String','Pixels','FontSize',10);

% plot max min and scale according to max magnetude
[Velmax Cmax] = max(VelDironeVelDataMask(:,:,SystoleFrame));
[Velmax Rmax] = max(Velmax);
[Velmin Cmin] = min(VelDironeVelDataMask(:,:,SystoleFrame));
[Velmin Rmin] = min(Velmin);
hold on
plot3(Rmax+.5,Cmax(Rmax)+.5,Velmax*2,'bo')
plot3(Rmin+.5,Cmin(Rmin)+.5,Velmax*2,'rs')

if abs(Velmax) >= abs(Velmin)
    climit = abs(Velmax);
else
    climit = abs(Velmin);
end
caxis([-climit climit]);


colorbar1 = colorbar([0.319 0.432 0.015 0.171],...
    'Box','on',...
    'XLim',[-0.5 1.5],...
    'Location','manual');


shearstressaxes = axes('OuterPosition', [0.395 .34 0.26 0.353]);
axes(shearstressaxes);
[Th2,rho2]=meshgrid(Th,(0:radialres:radiallimit)');
[X,Y]=pol2cart(Th2,rho2);
surf(X,Y,Tzr(:,:,SystoleFrame),'EdgeColor','none')

% scale accding to max magnetude
[Tzrmax Cmax] = max(Tzr(:,:,SystoleFrame));
[Tzrmax Rmax] = max(Tzrmax);
[Tzrmin Cmin] = min(Tzr(:,:,SystoleFrame));
[Tzrmin Rmin] = min(Tzrmin);
hold on
plot3(X(Cmax(Rmax),Rmax),Y(Cmax(Rmax),Rmax),Tzrmax*2,'bo');
plot3(X(Cmin(Rmin),Rmin),Y(Cmin(Rmin),Rmin),Tzrmax*2,'rs');
if abs(Tzrmax) >= abs(Tzrmin)
    climit = abs(Tzrmax);
else
    climit = abs(Tzrmin);
end
caxis([-climit climit]);

view(2); axis square; axis ij; box on; hold on
plot3(0,0,VENC/8,'+')
axis(limits)
colorbar1 = colorbar([0.64 0.432 0.015 0.171],...
    'Box','on',...
    'XLim',[-0.5 1.5],...
    'Location','manual');
hold off
title('Ax. WSS@Sys (dynes/cm^2)','FontSize',10,'FontWeight','Bold')
xlabel('Pixels','FontSize',10)
ylabel('Pixels','FontSize',10)


% calc and display regurgitant fraction, reverse flow, SRI, SRI@systole
htextaxes = axes('Position',[0 0 1 1],'Visible','off');

netFlow = positiveFlow+negativeFlow;
posInd  = find(netFlow>0);
negInd  = find(netFlow<0);
posVol  = sum(netFlow(posInd));
negVol  = sum(netFlow(negInd));
regurgFraction = abs(negVol)/posVol;

reverseFlowRat = abs(negativeFlow(SystoleFrame))/abs(positiveFlow(SystoleFrame));

%Calc SRI
asymIndex = (max(max(pWSS)) - min(min(pWSS)))/mean(abs(meanWSS));

%Calc SRI@systole
minWSSsys = min(pWSS(:,SystoleFrame));
maxWSSsys = max(pWSS(:,SystoleFrame));
tauDelta = maxWSSsys - minWSSsys;
taumean = mean(abs(meanWSS));
asymIndexsys = tauDelta/taumean;

%Calc SRI@T
for phase = 1:size(pWSS,2)
    minWSSt = min(pWSS(:,phase));
    maxWSSt = max(pWSS(:,phase));
    tauDelta(phase) = maxWSSt - minWSSt;
end
maxtauDelta = max(tauDelta);
taumean = mean(abs((meanWSS)));
asymIndexT = maxtauDelta/taumean;


    

numformat = '%6.2f';
xTextPos  = .771;
xTextPos2 = .948;
yTextPos  = .782;
yTextSpace= .01725;
alignment = 'left';
alignment2= 'right';

text(xTextPos,yTextPos,'Regurg. Frac. : ',...
    'Color','k','FontSize',8,'HorizontalAlignment',alignment);
text(xTextPos2,yTextPos,num2str(regurgFraction,numformat),...
    'Color','k','FontSize',8,'HorizontalAlignment',alignment2);

text(xTextPos,yTextPos-1*yTextSpace,'Flow Rev Rat.@Sys : '...
    ,'Color','k','FontSize',8,'HorizontalAlignment',alignment);
text(xTextPos2,yTextPos-1*yTextSpace,num2str(reverseFlowRat,numformat),...
    'Color','k','FontSize',8,'HorizontalAlignment',alignment2);

text(xTextPos,yTextPos-2*yTextSpace,'SRI : ',...
    'Color','k','FontSize',8,'HorizontalAlignment',alignment);
text(xTextPos2,yTextPos-2*yTextSpace,num2str(asymIndex,numformat),...
    'Color','k','FontSize',8,'HorizontalAlignment',alignment2);

text(xTextPos,yTextPos-3*yTextSpace,'SRI@T : ','Color','k',...
    'FontSize',8,'HorizontalAlignment',alignment);
text(xTextPos2,yTextPos-3*yTextSpace,num2str(asymIndexT,numformat),...
    'Color','k','FontSize',8,'HorizontalAlignment',alignment2);

text(xTextPos,yTextPos-4*yTextSpace,'Diam (Mn/Mx) : ','Color','k',...
    'FontSize',8,'HorizontalAlignment',alignment);
text(xTextPos2,yTextPos-4*yTextSpace,[num2str(2*sqrt(MinArea/pi),numformat) '/' num2str(2*sqrt(MaxArea/pi),numformat) ],...
    'Color','k','FontSize',8,'HorizontalAlignment',alignment2);

hrect = rectangle('Position',[xTextPos-.5*yTextSpace yTextPos-yTextSpace*4.5 xTextPos2-xTextPos+yTextSpace 5*yTextSpace]);
axis([0 1 0 1]);
%% Plot Legend for Local Tau values

hlegendaxes = axes('OuterPosition', [0.702 .34 0.26 0.353]);
plot(b(y,1,SystoleFrame)-centerx,b(x,2,SystoleFrame)-centery,'b','LineWidth',2);
view(2); axis square; axis ij;box on; hold on

% plot locations
th0   = find(pROI(:,1,SystoleFrame)>350 | pROI(:,1,SystoleFrame)<10); % find shear @ positions
th45  = find(pROI(:,1,SystoleFrame)>35 & pROI(:,1,SystoleFrame)<55);
th90  = find(pROI(:,1,SystoleFrame)>80 & pROI(:,1,SystoleFrame)<100);
th135 = find(pROI(:,1,SystoleFrame)>125 & pROI(:,1,SystoleFrame)<145);
th180 = find(pROI(:,1,SystoleFrame)>170 & pROI(:,1,SystoleFrame)<190);
th225 = find(pROI(:,1,SystoleFrame)>215 & pROI(:,1,SystoleFrame)<235);
th270 = find(pROI(:,1,SystoleFrame)>260 & pROI(:,1,SystoleFrame)<280);
th315 = find(pROI(:,1,SystoleFrame)>305 & pROI(:,1,SystoleFrame)<325);
thvars = {th0,th45,th90,th135,th180,th225,th270,th315};

for i = 1:8
    M = length(thvars{i});
    ind(i) = round(M/2);
end

pointgap = 2;
m1 = polar(pROI(th0(1),1,SystoleFrame)*pi/180,pROI(th0(1),2,SystoleFrame)/2+pointgap,'k<');
polar(pROI(th45(ind(2)),1,SystoleFrame)*pi/180,pROI(th45(ind(2)),2,SystoleFrame)/2+pointgap,'kv');
m2 = polar(pROI(th90(ind(3)),1,SystoleFrame)*pi/180,pROI(th90(ind(3)),2,SystoleFrame)/2+pointgap,'b^');
polar(pROI(th135(ind(4)),1,SystoleFrame)*pi/180,pROI(th135(ind(4)),2,SystoleFrame)/2+pointgap,'b<');
m3 = polar(pROI(th180(ind(5)),1,SystoleFrame)*pi/180,pROI(th180(ind(5)),2,SystoleFrame)/2+pointgap,'r>');
polar(pROI(th225(ind(6)),1,SystoleFrame)*pi/180,pROI(th225(ind(6)),2,SystoleFrame)/2+pointgap,'r^');
m4 = polar(pROI(th270(ind(7)),1,SystoleFrame)*pi/180,pROI(th270(ind(7)),2,SystoleFrame)/2+pointgap,'gv');
polar(pROI(th315(ind(8)),1,SystoleFrame)*pi/180,pROI(th315(ind(8)),2,SystoleFrame)/2+pointgap,'g>');
set(findobj(gca,'Type','line'), 'LineWidth',1)
set(m1,'MarkerFaceColor','k')
set(m2,'MarkerFaceColor','b')
set(m3,'MarkerFaceColor','r')
set(m4,'MarkerFaceColor','g')
plot(0,0,'+','MarkerEdgeColor','k')

axis(limits)
title('WSS Sampling Legend','FontSize',10,'FontWeight','Bold')
xlabel('Pixels','FontSize',10)
ylabel('Pixels','FontSize',10)

%% save to individual DB
% save wkspce variables no matter what
save(['_wkspce\' intrpmeth '_' WkspaceName],'WSSlocal','-append');
display(['Matlab WSS appended to' pwd '\_wkspace\' WkspaceName]);

%% Create master cell and save as csv
% create cell array containing the following: 
%     -Time resolved regional WSS
%     -Time-resolved diameter
%     -Time-resolved flow
%     -Peak velocity
%     -max/mean/min WSS
%     -oscillatory shear index

% preallocate cell for csv output
csvout = cell(29,t+2);
csvout(:,1) = {'time','area','q_antegrade','q_retrograde','q_net','wss_1'    ,'wss_2'    ,'wss_3'    ,'wss_4'    ,'wss_5'    ,'wss_6'    ,'wss_7'    ,'wss_8'    ,'wss_circmean' ,'','time_independant_vars','v_max','v_min','tstep_systole','regurg_frac','flow_reversal_ratio','osi_1','osi_2','osi_3','osi_4','osi_5','osi_6','osi_7','osi_8'};
csvout(:,2) = {'ms'  ,'cm^2','L/min'      ,'L/min'       ,'L/min','dyne/cm^2','dyne/cm^2','dyne/cm^2','dyne/cm^2','dyne/cm^2','dyne/cm^2','dyne/cm^2','dyne/cm^2','dyne/cm^2'    ,'',''                     ,'cm/s' ,'cm/s' ,'time step'    ,'rf'         ,'frr'                ,''     ,''     ,''     ,''     ,''     ,''     ,''     ,''     };
% store values in cell for csv output
csvout(1,3:end)    = num2cell(MagnetTT);       %time
csvout(2,3:end)    = num2cell(Areas);          %area
csvout(3,3:end)    = num2cell(negativeFlow);   %reverse flow
csvout(4,3:end)    = num2cell(positiveFlow);   %forward flow
csvout(5,3:end)    = num2cell(flowRateVsTime); %net flow rate
csvout(6:13,3:end) = num2cell(WSSlocal);       %local WSS
csvout(14,3:end)   = num2cell(meanWSS);        %circumferentially averaged WSS

csvout(17,3)       = num2cell(VelMax);         %max velocity over all time points
csvout(18,3)       = num2cell(VelMin);         %min velocitu over all time points  
csvout(19,3)       = num2cell(SystoleFrame);   %peak flow time point
csvout(20,3)       = num2cell(regurgFraction); %regurgitant fraction
csvout(21,3)       = num2cell(reverseFlowRat); %flow reversal ratio at systole
csvout(22:29,3)    = num2cell(OSIlocal);       %local osi

cell2csv(['_wkspce\' intrpmeth '_' WkspaceName(1:end-4) '.csv'],csvout)


%% now save to patient DB
if saveFLAG
    
    if strcmp(PatientDB,'BAV')
        WSSdir = 'E:\MRI_ImageData_Mfiles\BAV_DVD\_WSS_data';
    elseif strcmp(PatientDB,'PHT')
        WSSdir = 'D:\research\MR_PAH_CU\Uyen_MRI_WSS_Analysis(Hypoxic)\_WSS_data\';
    elseif strcmp(PatientDB,'Phantom')
        WSSdir = 'F:\Phantoms\PipePhantom\_flowCalcs';
    else
        WSSdir = pwd;
    end
    
    figure(shearplots)
    if isempty(filename)
        filename = 'DefaultName';
    end
    htit = get(flowplot,'Title');
    tit = get(htit,'String');
    tit = strcat(filename,':  ',tit);
    set(htit,'String',tit);
    htit = get(localmeans,'Title');
    tit = get(htit,'String');
    tit = strcat(filename,':  ',tit);
    set(htit,'String',tit)
    htit = get(shearstressaxes,'Title');
    tit = get(htit,'String');
    tit = strcat(filename,':  ',tit);
    set(htit,'String',tit)
    htit = get(hVelMap,'Title');
    tit = get(htit,'String');
    tit = strcat(filename,':  ',tit);
    set(htit,'String',tit)
    
    if ~strcmp(PatientDB,'Phantom')
        eval([filename '.WSSall=pWSS;']);
        eval([filename '.WSStheta=ti;']);
        eval([filename '.WSSlocal=WSSlocal;']);
        eval([filename '.WSSmean=meanWSS;']);
        eval([filename '.avglocalmean=taulocalmean;']);
        eval([filename '.OSI=OSIlocal;']);
        eval([filename '.VelMax=VelMax;']);
        eval([filename '.VelMaxSys=VelMaxSys;']);
        eval([filename '.VelMin=VelMin;']);
        eval([filename '.VelMinSys=VelMinSys;']);
        eval([filename '.WSSmax=max(max(pWSS));']);
        %enter max position here
        eval([filename '.WSSmin=min(min(pWSS));']);
        %enter min position here
        %     eval([filename '.WSSratio=WSSratio']);
        eval([filename '.Areas=Areas;']);
        eval([filename '.MaxArea=MaxArea;']);
        eval([filename '.MinArea=MinArea;']);
        eval([filename '.positiveFlow=positiveFlow;']);
        eval([filename '.negativeFlow=negativeFlow;']);
        eval([filename '.SystoleFrame=SystoleFrame;']);
        eval([filename '.regurgFraction=regurgFraction;']);
        eval([filename '.reverseFlowRat=reverseFlowRat;']); % at systole
        eval([filename '.MagnetTT=MagnetTT;']); 
    end

    cd(WSSdir) 
    if exist([PatientDB '_' PatientDB_type '_WSS_values.mat'],'file') > 0 
        load([PatientDB '_' PatientDB_type '_WSS_values.mat'],'PatientDemographics');
        Pind = ismember(PatientDemographics(:,1),filename);
        if ~isempty(find(Pind))
            Pinfocell = PatientDemographics(Pind,:);
            eval([filename '.Case=Pinfocell{1};']);
            eval([filename '.Age=Pinfocell{3};']); % if empty then not enrolled
            eval([filename '.Sex=Pinfocell{4};']);
            eval([filename '.Diag=Pinfocell{5};']);
            eval([filename '.Ht=Pinfocell{7};']);
            eval([filename '.Wt=Pinfocell{8};']);            
%             eval([filename '.Psys=Pinfocell{10}']);     these are required for distensibility sub routine       
%             eval([filename '.Pdia=Pinfocell{11}']); 
            
            % display patient information on graph
            axes(htextaxes)
            hrect2=rectangle('Position',[xTextPos-.5*yTextSpace yTextPos-yTextSpace*3.5 xTextPos2-xTextPos+yTextSpace 8*yTextSpace]);
            
            text(xTextPos,yTextPos+4*yTextSpace,'Age : '...
                ,'Color','k','FontSize',8,'HorizontalAlignment',alignment);
            text(xTextPos2,yTextPos+4*yTextSpace,Pinfocell(3),...
                'Color','k','FontSize',8,'HorizontalAlignment',alignment2);

            text(xTextPos,yTextPos+3*yTextSpace,'Sex : ',...
                'Color','k','FontSize',8,'HorizontalAlignment',alignment);
            text(xTextPos2,yTextPos+3*yTextSpace,Pinfocell(4),...
                'Color','k','FontSize',8,'HorizontalAlignment',alignment2);
            text(xTextPos,yTextPos+2*yTextSpace,'Diag:',...
                'Color','k','FontSize',8,'HorizontalAlignment',alignment);
            
            diagline  = Pinfocell{5};
            if length(diagline)>20
                diagline1 = diagline(1:20);
                diagline2 = diagline(21:end);
                text(xTextPos2,yTextPos+2*yTextSpace,diagline1,...
                    'Color','k','FontSize',8,'HorizontalAlignment',alignment2);
                text(xTextPos+.037,yTextPos+yTextSpace,diagline2,...
                    'Color','k','FontSize',8,'HorizontalAlignment',alignment);
                
            else
                htxtdiag  = text(xTextPos2,yTextPos+2*yTextSpace,diagline,...
                    'Color','k','FontSize',8,'HorizontalAlignment',alignment2);
            end
            
            if isempty(Pinfocell{3})
                errordlg(['Patient is not enrolled in this study! REASON: ' Pinfocell{6}]);
                
            else
                set(shearplots,'PaperPositionMode','auto');
                cd(WSSdir)
                print(shearplots,'-zbuffer', '-dtiff', [filename '_' PatientDB_type '_shearplot.tif']);
                save([WkgDir '\_wkspce\' WkspaceName])
                save([WSSdir '\' PatientDB '_' PatientDB_type '_WSS_values.mat'],'-append',filename);
            end
        else
            errordlg('Patient not be found in the Patient Demographic Database! Please check yourself... results will not be saved')
            set(shearplots,'PaperPositionMode','auto');
            cd(WkgDir)
            save([WkgDir '\_wkspce\' WkspaceName])
            print(shearplots,'-zbuffer', '-dtiff', [filename '_' PatientDB_type '_shearplots.tif']);
        end
    elseif strcmp(PatientDB,'Phantom')
        set(shearplots,'PaperPositionMode','auto');
        cd(WkgDir)

        save([WkgDir '\_wkspce\'  intrpmeth '_' WkspaceName ])
        cd([ WkgDir '\_flowCalcs\'])
        print(shearplots,'-zbuffer', '-dtiff', [filename '_' intrpmeth PatientDB_type '_shearplots.tif']);
    end
end

cd(WkgDir);